package com.dbexposer.db;

import java.util.HashMap;
import java.util.Map;

class DatabaseTypeVarContext {
	
	private static final Map<String, Class> VAR_TYPES;
	
	static {
		VAR_TYPES = new HashMap<String, Class>();

		VAR_TYPES.put("$url", String.class);
		VAR_TYPES.put("$user", String.class);
		VAR_TYPES.put("$password", String.class);
		VAR_TYPES.put("$host", String.class);
		VAR_TYPES.put("$port", Integer.class);
		VAR_TYPES.put("$dbname", String.class);
	}
	
	private final Map<String, Object> varValues;

	public DatabaseTypeVarContext(DatabaseType type, String url, String user, String password) {
		
		varValues = new HashMap<String, Object>();
		
		varValues.put("$url", url);
		varValues.put("$user", user);
		varValues.put("$password", password);
		// FIXME PARSE URL AND ADD PARSED VALUES TO VARVALUES
	}
	
	Class getVarType(String varName) {
		return VAR_TYPES.get(varName);
	}
	
	int getIntVar(String varName) {
		return Integer.valueOf(varValues.get(varName).toString());
	}
	
	String getStrVar(String varName) {
		return varValues.get(varName).toString();
	}

}
